//! $Id: Configuration.h 27 2011-09-16 13:28:08Z skagget77 $
//!
//! @File    Configuration.h
//! @Author  Johan Andersson <skagget77@gmail.com>
//! @Date    Thu Oct 01 20:21 2009
//! @Ingroup IoCpp
//!

#if !defined(IOCPP_CONFIG_CONFIGURATION_H)
#define IOCPP_CONFIG_CONFIGURATION_H

#include "IoCpp/IContainer.h"
#include "IoCpp/Config/BindContext.h"
#include "IoCpp/Config/ContextCommit.h"
#include "IoCpp/Config/ProviderContext.h"

#include <string>

namespace IoCpp
{
   //!
   //! @author  Johan Andersson <skagget77@gmail.com>
   //! @date    Thu Oct 01 20:21 2009
   //! @ingroup IoCpp
   //!
   //! The Configuration class, used to configure a container, that is binding
   //! constants or providers to types.
   //!
   class Configuration 
   {
   public :
      //!
      //! Creates a new instance of the Configuration class.
      //!
      //! @param container The container.
      //!
      Configuration( IContainerPtr container )
         : mContainer(container) {
      }

      //!
      //! Binds a constant or provider to a type.
      //!
      //! @return A ProviderContext.
      //!
      template<class T1>
      ProviderContext<T1> Bind()
      {
         ContextCommit<BindContext<T1> > commit;

         return ProviderContext<T1>(
            boost::shared_ptr<BindContext<T1> >(new BindContext<T1>(mContainer), commit)
         );
      }

   private :
      IContainerPtr mContainer;
   };
}

#endif   // IOCPP_CONFIG_CONFIGURATION_H
